package cn.yeziji.netty.adapter;

import cn.yeziji.forum.basic.netty.chat.ChatMessage;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;

/**
 * 退出私有聊天室适配器
 *
 * @author gzkemays
 * @since 2022/12/03 3:59 PM
 */
@Slf4j
public class PrivateChatExitAdapter extends SelectedTypes<ChatMessage>
    implements CommunicationAdapters {
  public PrivateChatExitAdapter(Integer type, String text) {
    super(type, text, ChatMessage.class);
  }

  @Override
  public void notice(ChannelHandlerContext channelHandlerContext) {
    getNettyWebsocketHandler().getPrivateMap().remove(this.data.getFrom().getUsername());
  }

  @Override
  public Object dispose(ChannelHandlerContext channelHandlerContext) {
    return null;
  }
}
